//
//  ShareItem.m
//  Shuaiche
//
//  Created by zzs on 2018/8/21.
//  Copyright © 2018年 zzs. All rights reserved.
//

#import "ShareItem.h"

@implementation ShareItem

- (instancetype)initWithSharedImage:(UIImage *)img andSharedURL:(NSURL *)sharedUrl;{
    if(self = [super init]){
        self.sharedImage = img;
        self.sharedUrl = sharedUrl;
    }
    return self;
}

-(instancetype)init
{
    @throw [NSException exceptionWithName:@"Do not use" reason:@"Please use initWithSharedImage:andSharedURL to initiate." userInfo:nil];
    return nil;
}

#pragma mark - UIActivityItemSource
-(id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController
{
    return self.sharedImage;
}

-(id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType{
    return self.sharedUrl;
}

-(UIImage*)activityViewController:(UIActivityViewController *)activityViewController thumbnailImageForActivityType:(NSString *)activityType suggestedSize:(CGSize)size
{
    // 为item提供缩略图，大小为建议的大小
    // 用自定义的UIImage的Category resize 类方法处理图片为缩略图
    return [UIImage imageNamed:@"image_default"];
}

-(NSString*)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(NSString *)activityType
{
    return @"多图分享";
}
-(NSString*)activityViewController:(UIActivityViewController *)activityViewController dataTypeIdentifierForActivityType:(NSString *)activityType
{
    return nil;
}


@end
